package control;
import model.*;
import db.*;

import java.util.ArrayList;

public class CustomerCtrl
{
	DBCustomer dbCust = new DBCustomer();
	
	public CustomerCtrl()
	{
		
	}
	
	public ArrayList<Customer> getAllCustomers()
	{
		ArrayList<Customer> allCust = new ArrayList<Customer>();
		allCust = dbCust.getAllCustomers(false);
		return allCust;
	}

	public Customer getCustomerFname(String fName)
	{
		return dbCust.getCustomerFname(fName, false);
	}
	
	public Customer getCustomerLname(String lName)
	{
		return dbCust.getCustomerLname(lName, false);
	}
	
	public Customer getCustomerID(String id)
	{
		return dbCust.getCustomerId(id, false);
	}
	
	public int updateCustomer(int groupId, String Fname, String Lname, String address, int zipCode, String city, int id)
	{
		Customer cust = new Customer();
		cust.setGroupId(groupId);
		cust.setFname(Fname);
		cust.setLname(Lname);
		cust.setAddress(address);
		cust.setZipCode(zipCode);
		cust.setCity(city);
		cust.setId(id);
		return dbCust.updateCustomer(cust);
	}
	
	public void deleteCustomer(String id)
	{
		dbCust.deleteCustomer(id);
	}
	
	public void insertCustomer(int groupId, String Fname, String Lname, String address, int zipCode, String city, int id) throws Exception
	{
		Customer toInsert = new Customer();
		toInsert.setGroupId(groupId);
		toInsert.setFname(Fname);
		toInsert.setLname(Lname);
		toInsert.setAddress(address);
		toInsert.setZipCode(zipCode);
		toInsert.setCity(city);
		toInsert.setId(id);
		dbCust.insertCustomer(toInsert);
	}
}
